/**
 * Camera.java
 * @author Niel Lebeck
 */

package engine;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;

/** 
* Displays section of Level. Can be controlled by a set origin as well as
* trigger events
*/
public abstract class Camera {
    private Level myLevel;
    private int myScreenHeight;
    private int myScreenWidth;

    /**
     * Returns height of screen display
     * 
     * @return height of display
     */
    public int getScreenHeight () {
        return myScreenHeight;
    }

    /**
     * Returns width of screen display
     * 
     * @return width of display
     */
    public int getScreenWidth () {
        return myScreenWidth;
    }

    /**
     * Sets level for camera to paint
     * 
     * @param l next level
     */
    public void setLevel (Level l) {
        myLevel = l;
    }

    /**
     * Returns reference to Level that is being displayed
     * 
     * @return current level
     */
    public Level getLevel () {
        return myLevel;
    }

    /**
     * Paints background and sprites included in controlled section of display
     * 
     * @param g Graphics drawing object
     */
    public void paintGame (Graphics g) {
        myLevel.paintBackground(g);
        Point origin = getCameraOrigin();
        myLevel.paintSprites(g, (int) origin.getX(), (int) origin.getY());
    }

    /**
     * Sets the dimensions of the display
     * 
     * @param d new screen dimension
     */
    public void setScreenDimensions (Dimension d) {
        myScreenHeight = (int) d.getHeight();
        myScreenWidth = (int) d.getWidth();
    }

    /**
     * Sets the dimensions of the display
     * 
     * @param w width of new display
     * @param h height of new display
     */
    public void setScreenDimensions (int w, int h) {
        myScreenWidth = w;
        myScreenHeight = h;
    }

    /**
     * Method to be implemented by subclasses:
     * Controls what section of the level is painted
     * Additionally, defines relative coordinates of the camera
     * 
     * @return point of reference
     */
    public abstract Point getCameraOrigin ();
}
